{include file="header.html"} 

<div class="row">
  <div class="span12"> {include file='coupon/nav.html'}
    <form method='post' action='{$appadmin}?m=coupon&a=save'>
      <input type='hidden' name='id' style='display:none;' value='{$data.id}' >
      <table class='table table-bordered' width='100%'>
        <tr>
          <td width="100">名称：</td>
          <td><input type='text' name='title' id='title' value='{$data.title}' ></td>
        </tr>
        
        <tr>
        	<td>限制次数</td>
            <td>
            	<input type="text" name="limit_num" value="{if !$data.limit_num}1{else}{$data.limit_num}{/if}"> (用户可以领取次数)
            </td>
        </tr>
        
        <tr>
          <td>使用范围：</td>
          <td>
          		<select name="type_id"   >
                	{foreach item=c key=k from=$type_list}
                	<option value="{$k}" {if $data.type_id eq $k} selected="selected"{/if}>{$c}</option>
                    {/foreach}
                </select>
                (学生街类型不能在此添加)
          </td>
        </tr>
        <tr>
          <td>抵消价格：</td>
          <td><input type='text' name='money' id='money'    value='{$data.money}' ></td>
        </tr>
        
        <tr>
          <td>最低消费价格：</td>
          <td><input type='text' name='lower_money' id='lower_money'    value='{$data.lower_money}' ></td>
        </tr>
        
        <tr>
          <td>总数量：</td>
          <td><input type='text' name='amount' id='amount'   value='{$data.amount}' ></td>
        </tr>
        <tr>
          <td>领取数量：</td>
          <td><input type='text' name='get_num' id='get_num'   value='{$data.get_num}' ></td>
        </tr>
        
        <tr>
          <td>使用数量：</td>
          <td><input type='text' name='use_num' id='use_num'    value='{$data.use_num}' ></td>
        </tr>
        <tr>
          <td>图片地址：</td>
          <td><div class="btn-upload" style="">
              <input type="file" class="btn-upload-file"   onChange="uploadimg()"  name="upimg" id="upimg" />
            </div>
            <input type='hidden' name='imgurl' id='imgurl' value='{$data.imgurl}' >
            <label  id="loading" style="color:red; display:none;">正在上传中...</label>
            <span id="imgShow"> {if $data.imgurl} <img src="/{$data.imgurl}.100x100.jpg"> {/if} </span></td>
        </tr>
        
        <tr>
          <td>截止日期：</td>
          <td><input type='text' name='end_time' id='end_time'   value='{if $data}{$data.end_time|date:Y-m-d H:i:s}{/if}'  onClick="WdatePicker({startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd HH:mm'})" ></td>
        </tr>
        {if $data}
        <tr>
          <td>创建时间：</td>
          <td>{$data.dateline|date:Y-m-d H:m}</td>
        </tr>
        {/if}
        <tr>
          <td>状态：</td>
          <td><input type='radio' name='status' id='status' value='1' {if $data.status eq 1} checked="checked" {/if} >
            显示
            <input type='radio' name='status' id='status' value='0' {if $data.status neq 1} checked="checked" {/if}>
            隐藏 </td>
        </tr>
        
        
        
        <tr>
          <td></td>
          <td><input type='submit' value='保存' class='btn btn-success'></td>
        </tr>
      </table>
    </form>
  </div>
</div>
<script language="javascript" src="/plugin/My97DatePicker/WdatePicker.js"></script>
<script language="javascript" src="/plugin/jquery/ajaxfileupload.js"></script> 
<script language="javascript">
   function uploadimg()
    {
		 
        //starting setting some animation when the ajax starts and completes
        $("#loading")
        .ajaxStart(function(){
            $(this).show();
        })
        .ajaxComplete(function(){
            $(this).hide();
        });

        $.ajaxFileUpload
        (
            {
                url:'/index.php?m=upload&a=uploadad&dir=coupon&t='+Math.random(), 
                secureuri:false,
                fileElementId:'upimg',
                dataType: 'json',
                success: function (data, status)
                {
                    if(typeof(data.error) != 'undefined')
                    {
                        if(data.error != '')
                        {
                           alert(data.msg);
                        }else
                        {
                             $("#imgShow").html("<img src='/"+data.imgurl+".100x100.jpg' width='100'>");
							 $("#imgurl").val(data.imgurl);
                        }
                    }
                },
                error: function (data, status, e)
                {
                    alert(e);
                }
            }
        )
        
        return false;

    }
	
  
</script> 
<script language="javascript">

$(document).ready(function(e) {
    $("#amount").bind("keyup",function(){
		$("#total_money").html($(this).val());
	});
});

</script>
{include file="footer.html"}